//
// Copyright © 2022 Hardcore Engineering Inc.
// 
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// 
// See the License for the specific language governing permissions and
// limitations under the License.
//

/* Huly Panels */
.hulyPanels-container {
  display: flex;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  background-color: var(--theme-navpanel-color); // var(--global-surface-01-BackgroundColor);
  border-radius: 0 var(--small-focus-BorderRadius) var(--small-focus-BorderRadius) 0;

  // .antiPanel-navigator {
  //   background-color: transparent;
  // }
  .antiPanel-component {
    border-radius: var(--small-focus-BorderRadius);
  }
}
.hulyNavPanel-container a.noUnderline {
  display: inline-flex;
  flex-shrink: 0;
  min-width: 0;
  min-height: 0;

  button.type-link { width: 100%; }
}
.hulyNavPanel-container .hulyNavItem-container,
.hulyNavPanel-container .hulyTaskNavLink-container,
.parentSelector .hulyNavItem-container {
  margin: 0 0.75rem;
}
.hulyNavPanel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  padding: var(--spacing-1_5) var(--spacing-1_5) var(--spacing-3) var(--spacing-2_5);
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1.5rem;
  color: var(--global-primary-TextColor);

  &:not(.withButton) {
    min-height: 4.25rem;
  }
  &.withButton {
    min-width: 0;
    min-height: 0;
  }
  &.small { padding-bottom: var(--spacing-1_5); }
}

.hulyNavGroup-container {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: 100%;
  min-width: 0;
  min-height: 0;

  .hulyNavGroup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    margin: 0;
    padding: var(--spacing-1) var(--spacing-2_25) var(--spacing-1) var(--spacing-2);
    min-height: var(--global-medium-Size);
    border: none;
    outline: none;

    &.disabled { cursor: default; }
    &__chevron,
    &__arrow,
    &__icon {
      display: flex;
      justify-content: center;
      align-items: center;
      flex-shrink: 0;
    }
    &__chevron {
      margin: 0 0.125rem;
      width: 1.25rem;
      height: 1.25rem;
      color: var(--global-disabled-TextColor);
      border: 1px solid transparent;
      border-radius: var(--extra-small-BorderRadius);

      & > * {
        transform-origin: center;
        transform: rotate(0deg);
        transition: transform 0.1s ease-in-out;
      }
      &.collapsed > * { transform: rotate(-90deg); }
    }
    &__icon {
      margin: 0 0.125rem;
      width: 1.5rem;
      height: 1.5rem;
      color: var(--global-primary-TextColor);
      background-color: var(--theme-navpanel-selected);
      border: 1px solid var(--global-subtle-ui-BorderColor);
      border-radius: var(--extra-small-BorderRadius);
      
      &.folder {
        background-color: var(--theme-statusbar-color);
        border-color: var(--global-surface-01-BorderColor);
      }
    }
    &__label {
      display: inline-flex;
      align-items: center;
      gap: var(--spacing-0_5);
      padding: var(--spacing-0_25) var(--spacing-0_5);
      min-width: 0;
      text-transform: uppercase;
      color: var(--global-tertiary-TextColor);
      border-radius: var(--extra-small-BorderRadius);
    }
    &__tools {
      display: none;
      align-items: center;
      flex-shrink: 0;
      gap: var(--spacing-0_5);
      margin-left: var(--spacing-1);
      min-width: 0;
      max-width: 50%;
    }
    &__arrow {
      margin-left: var(--spacing-0_5);
      width: var(--global-min-Size);
      height: var(--global-min-Size);
      color: var(--global-accent-IconColor);
    }

    &.showMenu,
    &.highlighted,
    &.selected,
    &:hover {
      .hulyNavGroup-header__tools { display: flex; }
    }
    &.showMenu,
    &.highlighted,
    &.selected {
      .hulyNavGroup-header__label { background-color: var(--global-ui-BackgroundColor); }
      .hulyNavGroup-header__chevron { color: var(--global-tertiary-TextColor); }
      .hulyNavGroup-header__label { color: var(--global-secondary-TextColor); }
    }
    &.selected { background-color: var(--global-ui-highlight-BackgroundColor); }
    &.isOpen + .hulyNavGroup-content {
      max-height: 100%;

      &:not(:has(.nested)) { margin-bottom: var(--spacing-1_5); }
    }
  }
  &.nested .hulyNavGroup-header {
    .hulyNavGroup-header__icon { margin: 0 var(--spacing-0_25) 0 0; }
    .hulyNavGroup-header__label { padding: 0 var(--spacing-0_75) 0 0; }
    &.isOpen .hulyNavGroup-header__label { background-color: var(--global-ui-BackgroundColor); }
  }
  .hulyNavGroup-header:hover,
  &.nested .hulyNavGroup-header:hover {
    .hulyNavGroup-header__chevron { background-color: var(--global-ui-BackgroundColor); }
    .hulyNavGroup-header__label { background-color: var(--global-ui-hover-BackgroundColor); }
    .hulyNavGroup-header__chevron { color: var(--button-subtle-IconColor); }
    .hulyNavGroup-header__label { color: var(--global-primary-TextColor); }
  }
  &.nested.selectable .hulyNavGroup-header {
    margin: 0 var(--spacing-1_5) var(--spacing-1_5);
    padding: var(--spacing-0_5) var(--spacing-0_75) var(--spacing-0_5) var(--spacing-0_5);
    min-height: var(--global-small-Size);
    border-radius: var(--small-BorderRadius);

    &.selected { padding-right: var(--spacing-0_75); }
    &.isOpen { margin-bottom: 0; }
  }

  &:not(.nested, .noDivider),
  &.noDivider + &.noDivider { border-top: 1px solid var(--theme-navpanel-divider); }

  .hulyNavGroup-content {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0;
    min-width: 0;
    max-height: 0;
  }
}
.hulyNavItem-container + .hulyNavGroup-container,
.hulyNavPanel-container a.noUnderline + .hulyNavGroup-container { margin-top: .75rem; }

.hulyNavItem-container .hulyNavItem-chevron:enabled {
  & > * {
    transform-origin: center;
    transform: rotate(-90deg);
    transition: transform 0.1s ease-in-out;
  }
  &.isOpen > * { transform: rotate(0deg); }
}

.hulySidePanel-container {
  display: flex;
  flex-direction: column;
  width: 10rem;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border-radius: 0 var(--small-focus-BorderRadius) var(--small-focus-BorderRadius) 0;
}

/* Dialogs */
.antiPanel {
  overflow: hidden;
  min-width: 400px;

  background-color: var(--theme-popup-color);
  border: 1px solid var(--theme-popup-divider);
  border-radius: .5rem;
  flex-direction: row;
  box-shadow: var(--theme-popup-shadow);
  // left: 1rem;

  &.float {
    position: fixed;
    display: flex;
    flex-direction: column;
    top: 5rem;
    right: .5rem;
    width: 42rem;
    height: auto;
    min-height: 0;
    max-height: 32rem;
    z-index: 500;

    .ap-header {
      flex-shrink: 0;
      padding: 1.5rem 1.75rem .5rem;
      width: 100%;
      min-width: 0;
      min-height: 0;
    }
  }

  .ac-header {
    &.highlight { background-color: var(--accent-bg-color); }
    &.divide { border-bottom: 1px solid var(--divider-color); }
  }
  .ad-section-50 {
    display: flex;
    flex-direction: column;
    flex-basis: 50%;
    min-height: 0;
    width: 50%;

    &.divide { border-right: 1px solid var(--divider-color); }
  }
  .ad-tools {
    position: absolute;
    display: flex;
    top: 1.25rem;
    right: 1.25rem;

    &.grow-reverse {
      display: flex;
      flex-direction: row-reverse;
      justify-content: flex-end;
      align-items: center;
    }
  }
}

.popupPanel {
  overflow: hidden;
  display: flex;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border-radius: var(--small-focus-BorderRadius);

  &:not(.rowContent) { flex-direction: column; }
  .panel-instance & {
    background-color: var(--theme-panel-color);
    border: 1px solid var(--theme-divider-color);
  }

  .popupPanel-title {
    display: flex;
    flex-shrink: 0;
    justify-content: stretch;
    align-items: center;
    min-width: 0;
    min-height: 3.5rem;
    background-color: var(--theme-comp-header-color);
    border-bottom: 1px solid var(--theme-divider-color);

    &:not(.indent) { padding: 0 1rem 0 1.25rem; }
    &.indent { padding: 0 1rem; }
    &__content {
      display: flex;
      align-items: center;
      flex-grow: 1;
      margin-right: .75rem;
      min-width: 0;
      min-height: 0;

      .title {
        min-width: 0;
        padding: .125rem .375rem;
        font-size: .8125rem;
        color: var(--theme-content-color);
        background-color: var(--theme-breadcrumb-default);
        border-radius: .25rem;

        &:not(:last-child) { margin-right: .125rem; }
        &:not(.disabled, .not-active) {
          cursor: pointer;

          &:hover, &:focus { background-color: var(--theme-breadcrumb-hovered); }
          &:active { background-color: var(--theme-breadcrumb-pressed); }
          &:hover, &:focus, &:active { color: var(--theme-caption-color); }
        }
        &.disabled { color: var(--theme-dark-color); }
        &.not-active {
          color: var(--theme-caption-color);
          user-select: text;
        }
      }
    }
  }

  .popupPanel-body {
    overflow: hidden;
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    background-color: var(--theme-panel-color);
    // border: 1px solid var(--theme-divider-color);
    border-top: none;
    border-left: none;

    &.main {
      justify-content: stretch;
    }
    &.mobile {
      justify-content: center;
    }
    &__main, &__mobile, &__aside {
      overflow: hidden;
      display: flex;
      flex-direction: column;
      min-width: 0;
      min-height: 0;
    }
    &__main, &__aside {
      height: 100%;
    }
    &__mobile {
      flex-grow: 1;
    }
    
    &__main {
      flex-grow: 2;
      flex-basis: 760px;
      border: none;
      border-radius: 0;

      &-content {
        display: flex;
        flex-direction: column;
        // flex-shrink: 0;
        margin-left: auto;
        margin-right: auto;
        width: calc(100% - 7.5rem);
        max-width: 54rem;

        &.max {
          max-width: 100%;
        }
      }
    }

    .popupPanel-body__header {
      display: flex;
      align-items: center;
      min-height: 0;

      &-wrapper {
        display: flex;
        justify-content: center;
        align-items: center;
        flex-shrink: 0;
        width: 100%;
        min-width: 0;
        min-height: 3.5rem;
        border-bottom: 1px solid var(--theme-divider-color);
      }
      &.main {
        padding: .75rem 1.25rem;
        width: calc(100% - 5rem);
        height: 100%;
        min-width: 0;
        max-width: 900px;

        &.max {
          max-width: 100%;
        }
      }
      &.mobile {
        flex-shrink: 0;
        padding: .5rem .75rem .75rem;
        width: 100%;
        min-width: 320px;
      }

      &.bottom-divider { border-bottom: 1px solid var(--theme-divider-color); }
      &.top-divider { border-top: 1px solid var(--theme-divider-color); }
      .header-row {
        display: flex;
        align-items: center;
        width: 100%;
        min-width: 0;
        flex-wrap: wrap;

        &.between { justify-content: space-between; }
      }
      .header-row + .header-row { margin-top: .625rem; }
    }
    .popupPanel-body__mobile-content {
      padding: .5rem;
      min-width: 320px;
    }

    &__aside {
      width: 25%;
      min-width: var(--panel-aside-width);
      
      &.float {
        position: absolute;
        flex-direction: row;
        flex-shrink: 0;
        top: 0;
        left: 100%;
        width: var(--panel-aside-width);
        height: 100%;
        min-width: 0;
        min-height: 0;
        background-color: var(--theme-panel-color);
        // border-left: 1px solid var(--theme-divider-color);
        border-bottom-right-radius: .45rem;
        box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
        transition: box-shadow 150ms ease 0s, transform 150ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
        transform: translateX(0);
        visibility: hidden;

        &.shown {
          box-shadow: var(--popup-aside-shadow);
          transform: translateX(-100%);
          visibility: visible;
        }
      }

      &-header,
      &-tabsheader {
        display: flex;
        align-items: center;
        flex-shrink: 0;
        height: 3.5rem;
        min-height: 3.5rem;
        border-bottom: 1px solid var(--theme-divider-color);
      }
      &-tabsheader { padding: 0 2rem; }
      &-header {
        justify-content: space-between;
        padding: .75rem .75rem .75rem 2rem;
      }

      &-grid {
        display: grid;
        grid-template-columns: 1fr 1.5fr;
        grid-auto-rows: minmax(2rem, max-content);
        justify-content: start;
        align-items: center;
        row-gap: .25rem;
        column-gap: 1rem;
        margin: .25rem 2rem 0;
        width: calc(100% - 4rem);
        height: min-content;

        &.inCollapsed { margin: 1rem 2rem; }
        .divider {
          grid-column: 1 / 3;
          margin: .75rem -2rem;
          height: 1px;
          background-color: var(--theme-divider-color);
        }
        .labelOnPanel,
        .labelTop { color: var(--theme-dark-color); }
        .labelTop {
          align-self: start;
          margin-top: .4rem;
        }
        .textPadding { margin-left: .875rem; }
      }
      &-content {
        display: flex;
        flex-direction: column;
        width: 100%;
        min-width: 0;
        min-height: 0;
        padding: 1.25rem 2rem;
      }
      .space-divider {
        flex-shrink: 0;
        height: .75rem;

        &.bottom { height: 1.25rem; }
      }
    }

    @media print {
      border: none;
    }

    // &.asideShown .popupPanel-body__main {
    //   border: 1px solid var(--divider-color);
    //   border-radius: 0 0 .5rem .5rem;
    // }
  }

  .popupPanel-pageHeader {
    @include watermark;

    top: 0;
    width: 100%;
    visibility: hidden;
  }
  
  .popupPanel-pageFooter {
    @include watermark;

    bottom: 0;
    width: 100%;
    visibility: hidden;
  }

  @media print {
    overflow: visible;
  }
}
.popupPanel .popupPanel-body__aside .popupPanel-body__aside-grid + .popupPanel-title {
  border-top: 1px solid var(--theme-divider-color);
}

// Full size state
.popup.fullsize .popupPanel {
  border-radius: 0;
  box-shadow: none !important;

  .popupPanel-title,
  .popupPanel-body {
    // border-radius: 0;
    border: none;
  }
}
.popup.fullsize {
  transition-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19) !important;
}
